<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
    <!--{include file="comm_header.tpl"}-->
</head>
<body ontouchstart style="background: #ebebeb;">
<div class="container" id="container">
    <div class="page" style="margin-bottom: 45px">
        <div class="weui-tab">
            <div class="weui-navbar">
                <div class="weui-navbar__item weui-bar__item_on">
                    <span>制作中</span>
                </div>
                <div class="weui-navbar__item">
                    <span>制作完成</span>
                </div>
            </div>
            <div class="weui-tab__panel">
                <!-- 制作中 -->
                <div id="divProces" class="weui-tab__content" style="display: block">
                </div>
                <!-- 制作中 END -->

                <!-- 销售订单 -->
                <div id="divFinish" class="weui-tab__content">
                </div>
                <!-- 销售订单END -->
            </div>
        </div>
    </div>
    <div class="weui-footer weui-footer_fixed-bottom">
        <a href="javascript:void(0);" id="scanQRCode" class="weui-btn weui-btn_primary"">扫一扫 <i class="icon iconfont icon-richscan_icon"></i></a>

    </div>
</div>
<!--{include file="comm_js.tpl"}-->
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>

<script type="text/javascript">
    wx.config({
        debug: false,
        appId: '<!--{$signPackage["appId"]}-->',
        timestamp: <!--{$signPackage["timestamp"]}-->,
        nonceStr: '<!--{$signPackage["nonceStr"]}-->',
        signature: '<!--{$signPackage["signature"]}-->',
        jsApiList: [
            'scanQRCode'
        ]
    });

    wx.ready(function () {
        // 在这里调用 API
        document.querySelector('#scanQRCode').onclick = function () {
            wx.scanQRCode({
                needResult: 1,
                desc: 'scanQRCode desc',
                success: function (res) {
                    location.href = '/wap/orderDtl.html?ajaxFlg=2&code='+res.resultStr;
                }
            });
        };
    });

    $(function(){
        $('.weui-navbar__item').on('click', function () {
            var _this=$(this).index()
            $(this).addClass('weui-bar__item_on').siblings('.weui-bar__item_on').removeClass('weui-bar__item_on');
            $(".weui-tab__content").eq(_this).show().siblings('.weui-tab__content').hide()
        });

        bindData(0);    //制作中
        bindData(1);    //制作完成
    });

    function tempDtl ( code ) {
        location.href = '/wap/orderDtl.html?ajaxFlg=2&code=' + code;
    }
    function bindData(type) {
        E.ajax_post({
            url : "/wap/order.html?ajaxFlg=2&status="+type,
            call : function (o) {
                if(o.code == 200){
                    var html = '';
                    $.each(o.data, function (i, v) {
                        html += '<div class="weui-form-preview">';
                        html += '   <div class="weui-form-preview__bd">';
                        html += '       <div class="weui-form-preview__item">';
                        html += '           <label class="weui-form-preview__label"><span class="text-gray">项目名称：</span><span class="text-blue">'+ v['tempName'] +'</span></label>';
                        html += '           <span class="weui-form-preview__value"><span class="text-gray">要求完成时间：</span>'+ v['requestDate'] +'</span>';
                        html += '       </div>';
                        html += '       <div class="weui-form-preview__item">';
                        html += '           <label class="weui-form-preview__label"><span class="text-gray">涂装体系：</span>'+ v['categoryName'] +'</label>';
                        html += '           <span class="weui-form-preview__value"></span>';
                        html += '       </div>';
                        html += '       <div class="weui-form-preview__item weui_describe">';
                        html += '           <label class="weui-form-preview__label"><span class="text-gray">制作内容：<br>及要求&nbsp;</span></label>';
                        html += '           <p>'+ v['request'] +'</p>';
                        html += '       </div>';
                        html += '   </div>';
                        html += '   <div class="weui-form-preview__ft">';
                        html += '       状态 : <span class="text-red">'+ v['statusName'] +'</span>';
                        html += '       <a class="weui-btn weui-btn_plain-default full-right" href="javascript:tempDtl(\''+ v['tempCode'] +'\')">查看详情</a>';
                        html += '   </div>';
                        html += '</div>';
                    });

                    var dId =  type ? 'divFinish' : 'divProces';
                    $("#"+dId).html(html);
                }
            }
        });
    }
</script>
</body>
</html>
